<template>
  <div class="wrapper">
    <div class="swiper-wrap">
      <swiper :options="swiperOption" ref="mySwiper" v-if="showSwiper">
        <!-- slides -->
        <swiper-slide v-for="item of list" :key="item.id">
          <img class="swiper-img" :src="item.imgUrl" alt="">
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        loop: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false,
        pagination: '.swiper-pagination'
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import '~s/varibles.styl'
    .wrapper >>> .swiper-pagination-fraction, .swiper-pagination-custom, .swiper-container-horizontal > .swiper-pagination-bullets
      bottom 3px !important
    .wrapper >>> .swiper-pagination-bullet-active
      background #fff !important
    .swiper-wrap
      width 100%
      height 0
      overflow hidden
      padding-bottom 31.25%
      .swiper-img
        width 100%
</style>
